/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved.
 * Description: hcclcpu侧接口类对外头文件
 * Author: gaozhenyue
 * Create: 2024-04-03
 */

#ifndef HCCL_COMM_CPU_H
#define HCCL_COMM_CPU_H

#include "../common/hccl_comm_base.h"

namespace hccl {
typedef void *tStream_t;

class HcclCommCpu : public HcclCommBase {
public:

    explicit HcclCommCpu(u64 inCCLbufferSize = 0, u64 outCCLbufferSize = 0, std::string identifier = "");
    explicit HcclCommCpu(s64 timeout = 0, u64 inCCLbufferSize = 0, u64 outCCLbufferSize = 0, std::string identifier = "");

    ~HcclCommCpu();

    HcclResult CreateGroup(const std::string &group, const u32 &groupRank, const u32 &userRank,
                                 const std::vector<u32> &groupRanks, std::shared_ptr<HcclCommBase> &groupComm) override;
    HcclResult InitImpl(DevType deviceType) override;
    HcclResult send(const std::string &tag, void *inputPtr, u64 count, HcclDataType dataType, u32 destRank,
        tStream_t stream);

    HcclResult receive(const std::string &tag, void *outputPtr, u64 count, HcclDataType dataType, u32 srcRank,
        rtStream_t stream);
    HcclResult GatherByOs(void* inputBuf, uint64_t inputCount, HcclDataType inputType, void* outputBuf,
        uint64_t outputCount, HcclDataType outputType, int root, uint64_t flag, const std::string &tag);

    HcclResult BcastByOS(void* buf, uint64_t count, HcclDataType dataType,
        int root, uint64_t flag, const std::string &tag);

    HcclResult PrepareStart(const std::string &tag, void *addr, u64 count, HcclDataType dataType, u32 destRank);
    HcclResult PrepareStartColl(const std::string &tag, const HcomCollOpInfo &opInfo, HcomOperationType opType);
    HcclResult PrepareCancel(const std::string &tag, u32& status);
    HcclResult PrepareQuerry(const std::string &tag, u32& status);
    HcclResult GetHeterogCollTag(HcomOperationType opType, std::string &tag);
};
}
#endif